package com.zhentao.controller;

import com.zhentao.common.dtos.ResponseResult;
import com.zhentao.service.AppUserService;
import com.zhentao.user.dto.UserManageDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api("/userManage")
@RestController
@RequestMapping("/mng/userManage")
public class UserManageController {

    @Resource
    private AppUserService appUserService;

    /**
     * 后台  普通用户管理 列表展示
     * @param dto
     * @return
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "UserManageDto", name = "dto", value = "", required = true)
    })
    @ApiOperation(value = "后台  普通用户管理 列表展示", notes = "后台  普通用户管理 列表展示", httpMethod = "POST")
    @PostMapping("/list/user")
    public ResponseResult userList(@RequestBody UserManageDto dto){
        return appUserService.userList(dto);
    }

    /**
     * 后台  普通用户 禁用
     * @param id
     * @param status
     * @return
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", dataType = "int", name = "id", value = "", required = true),
            @ApiImplicitParam(paramType = "path", dataType = "int", name = "status", value = "", required = true)
    })
    @ApiOperation(value = "后台  普通用户 禁用", notes = "后台  普通用户 禁用", httpMethod = "POST")
    @PostMapping("/list/delUser/{id}/{status}")
    public ResponseResult MangeUser(@PathVariable("id") Integer id,@PathVariable("status") Integer status){
        return appUserService.MangeUser(id , status);
    }


    /**
     * 后台 查看普通用户 个人资料
     * @param id
     * @return
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", dataType = "int", name = "id", required = true)
    })
    @ApiOperation(value = "后台 查看普通用户 个人资料", notes = "后台 查看普通用户 个人资料", httpMethod = "POST")
    @PostMapping("/list/selUserInfoById/{id}")
    public ResponseResult selectUserInfo(@PathVariable Integer id){
        return appUserService.selectUserInfo(id);
    }


    @PostMapping("/selectById/{id}")
    public ResponseResult selectById(@PathVariable Integer id){
        return appUserService.selectById(id);
    }

}
